package edu.jxnu.zhangjinsong.unemploymenttracker.service;

import edu.jxnu.zhangjinsong.unemploymenttracker.entity.Job;
import edu.jxnu.zhangjinsong.unemploymenttracker.mapper.JobMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobService {

    @Autowired
    private JobMapper jobMapper;

    /**
     * 获取所有岗位信息
     */
    public List<Job> getAllJobs() {
        return jobMapper.findAll();
    }

    /**
     * 根据ID获取岗位信息
     */
    public Job getJobById(String id) {
        return jobMapper.findById(id);
    }

    /**
     * 保存岗位信息
     */
    public boolean saveJob(Job job) {
        return jobMapper.insert(job) > 0;
    }

    /**
     * 更新岗位信息
     */
    public boolean updateJob(String id, Job jobDetails) {
        jobDetails.setId(id);
        return jobMapper.update(jobDetails) > 0;
    }

    /**
     * 删除岗位信息
     */
    public boolean deleteJob(String id) {
        return jobMapper.delete(id) > 0;
    }
}